﻿using HuaHan.WorkTicket.Domain.Model;
using HuaHan.WorkTicket.Domain.Repositories.EntityFramework.ModelConfigurations;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HuaHan.WorkTicket.Domain.Repositories.EntityFramework
{
    public sealed class WorkTicketDBContext : DbContext
    {
        #region Ctor
        /// <summary>
        /// 构造函数，初始化一个新的<c>ByteartRetailDbContext</c>实例。
        /// </summary>
        public WorkTicketDBContext()
            : base("WorkTicketDB")
        {
            this.Configuration.AutoDetectChangesEnabled = true;
            this.Configuration.LazyLoadingEnabled = true;

            Database.SetInitializer<WorkTicketDBContext>(new DatabaseInitializer()); 

        }
        #endregion


        #region Public Properties
        /// <summary>
        /// Gets a set of <c>User</c>s.
        /// </summary>
        
        public DbSet<Color> Colors
        {
            get { return Set<Color>(); }
        }

        public DbSet<Department> Departments
        {
            get { return Set<Department>(); }
        }

        public DbSet<Menu> Menus
        {
            get { return Set<Menu>(); }
        }

        public DbSet<Group> Groups
        {
            get { return Set<Group>(); }
        }


        public DbSet<GroupRole> GroupRoles
        {
            get { return Set<GroupRole>(); }
        }

        public DbSet<Customer> Customers
        {
            get { return Set<Customer>(); }
        }

        public DbSet<StyleCategory> StyleCategories
        {
            get { return Set<StyleCategory>(); }
        }

        public DbSet<Style> Styles
        {
            get { return Set<Style>(); }
        }

        public DbSet<Size> Sizes
        {
            get { return Set<Size>(); }
        }


        public DbSet<Unit> Units
        {
            get { return Set<Unit>(); }
        }

        public DbSet<ColorGroup> ColorGroups
        {
            get { return Set<ColorGroup>(); }
        }


        public DbSet<ColorGroupColor> ColorGroupColors
        {
            get { return Set<ColorGroupColor>(); }
        }

        public DbSet<SizeGroup> SizeGroups
        {
            get { return Set<SizeGroup>(); }
        }


        public DbSet<SizeGroupSize> SizeGroupSizes
        {
            get { return Set<SizeGroupSize>(); }
        }

        public DbSet<Employee> Employees
        {
            get { return Set<Employee>(); }
        }


        #endregion

        #region Protected Methods
        //protected override void OnModelCreating(DbModelBuilder modelBuilder)
        //{
        //    modelBuilder
        //        .Configurations
        //        .Add(new ColorConfiguration())
        //        .Add(new DepartmentConfiguration())
        //        .Add(new MenuConfiguration());
        //    .Add(new StyleCategoryConfiguration())
        //    .Add(new GroupRoleConfiguration())
        //    .Add(new GroupConfiguration())
        //    .Add(new UserConfiguration());
        //    base.OnModelCreating(modelBuilder);
        //    throw new UnintentionalCodeFirstException();
        //}
        #endregion

    }
}
